// pages/charge/house/house_detail/house_detail.js

const app = getApp() // 获取应用实例
import { getRoomDetail } from '../../../../utils/http/api'

Page({

  data: {

    // 记录传过来的id
    id: '',
    /** 房间详情 数据格式
    { "id": '',"type": 0,"name": "二号","owner_name": "","owner_tel": "", "rooms": 1,"unit": "","desc": "","enter_time": '',"total_area": "",
    "identity": "", "rent": "10","nature": 2,"deposit": "20.00","end_time": 1656604800, }
     */
    detail: {},

  },

  // 请求房间详情 getRoomDetail
  async reqRoomDetail() {
    wx.showLoading({ title: '处理中', mask: true, })
    let { code, msg, data } = await getRoomDetail({ id: this.data.id, token: app.gl.token })
    console.log(`reqRoomDetail...code=${code},msg=${msg},data=`, data)
    if (code == '1') {
      this.setData({ detail: data });
    } else {
      wx.showToast({ title: msg, icon: 'error' })
    }
  },

  // 生命周期函数--监听页面加载
  onLoad: function (options) {
    this.setData({ id: options.id, })
    this.reqRoomDetail();
  },

  // 生命周期函数--监听页面显示
  onShow: function () {

  },

  // 页面相关事件处理函数--监听用户下拉动作
  onPullDownRefresh: function () {

  },

})